import type { DividerAlign } from './types';

export function getAlignWidth(align: DividerAlign) {
  const widths: {
    left: number | string | undefined;
    right: number | string | undefined;
  } = {
    left: undefined,
    right: undefined,
  };
  if (align === 'left') {
    widths.left = 30;
    widths.right = undefined;
  } else if (align === 'right') {
    widths.left = undefined;
    widths.right = 30;
  } else if (align === 'center') {
    widths.left = undefined;
    widths.right = undefined;
  } else if (Array.isArray(align)) {
    const [left, right] = align;
    widths.left = left;
    widths.right = right;
  } else {
    // 穷尽检查
    const _align: never = align;
    console.error('Divider align 属性不合法', _align);
  }
  return widths;
}
